<template>
  <div>
    <van-swipe-cell v-for="item in userList">
      <van-cell
        :value="item.nickname"
        label="描述信息"
        center
        @click="userInfo(item)"
      >
        <template #icon>
          <img :src="item.headImg" alt />
        </template>
      </van-cell>
      <template #right>
        <van-button
          @click="delChat"
          class="delete-button"
          square
          type="danger"
          text="删除"
        />
      </template>
    </van-swipe-cell>
  </div>
</template>

<script>
import { getUserList } from "@/api/request/login.js";
export default {
  data() {
    return {
      userList: [],
    };
  },
  created() {
    this.getUserList();
  },
  methods: {

    // ````````````````````````````````````````````````````
    getUserList() {
      getUserList({
        pageNo: 1,
        pageSize: 20,
      })
        .then((res) => {
          this.userList = res.data.data;
        })
        .catch((err) => {});
    },
    userInfo(value) {
      this.$router.push({
        name: "chatWindows",
        params: value,
      });
    },
    delChat() {
      console.log("删除该用户的聊天窗口");
    },
  },
};
</script>

<style scoped>
img {
  height: 40px;
  width: 40px;
  margin-right: 10px;
}
.delete-button {
  height: 100%;
}
</style>